home *** CD-ROM | disk | FTP | other *** search
- Path: lrz-muenchen.de!news
- From: watzka@stat.uni-muenchen.de (Kurt Watzka)
- Newsgroups: comp.lang.c,comp.graphics.algorithms,rec.games.programmer
- Subject: Re: Speed question here...
- Date: 15 Feb 1996 10:17:25 GMT
- Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
- Distribution: world
- Message-ID: <4fv17l$o23@sparcserver.lrz-muenchen.de>
- References: <4ftluh$1gkv@hearst.cac.psu.edu>
- NNTP-Posting-Host: sun2.lrz-muenchen.de
-
- koscho@wjk130.rh.psu.edu (William Koscho) writes:
-
- >I was curious as to how fast something like the
- >following would execute:
-
- > int x;
- > node *ptr; ptr in linked list
-
- > for ( ptr = first_node; ptr != NULL; ptr = ptr.next ) {
- > for ( x = 0; x < max; x++ ) {
- > array[x] = array_other[x];
- > }
- > }
-
- >I really am not interested in the assignment statement, that's easy.
- >but the traversal through the linked list, and inner integer incremental
- >for loop for each node visited. How fast is a traversal through
- >a linked list when you do a for loop at each node?
-
- 1) Since this code cannot be compiled, discussions about it's execution
- speed are not very meaningful.
-
- 2) Compile the code for your target machine, using your target compiler.
- Then time it on your target machine. The C programming language does
- not enforce certain optimaization techniques, even if some of them
- are easier for C programs, while others are more difficult.
-
- Kurt
- --
- | Kurt Watzka Phone : +49-89-2180-6254
- | watzka@stat.uni-muenchen.de
- | ua302aa@sunmail.lrz-muenchen.de
-
-